<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet SYSTEM "lang://blogs">

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	
	
	<xsl:include href="../../main.xsl" />
	<xsl:include href="../menu.xsl" />
	
	<!-- Запускаем рендер страницы -->
	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/blogs.css" type="text/css" media="all" />
			<script type="text/javascript" src="{$baseURI}/js/blogs.js" />
			<script type="text/javascript" src="{$baseURI}/js/editBlogMembers.js" />
		</head>
		<body>
			
			<xsl:call-template name="top-userbar" />
			
			<!-- Header -->
			<div id="header">
				<xsl:call-template name="logo" />
				
				<!-- Menu -->
				<xsl:call-template name="menu" />
			</div>
			<!-- /Header -->
			
			<!-- Blocks -->
			<div id="blocks">
				<div id="blocks_inner">
					<xsl:call-template name="default-blocks-top" />
				</div>
			</div>
			<!-- // Blocks -->
			
			<!-- Content -->
			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="response" />
				</div>
			</div>
			<!-- // Content -->
			
			<!-- Address -->
			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="response">
		<h1>&labelEditBlog;</h1>
		<div id="small_menu">
			<a href="{$baseURI}/blogs/edit_blog/{@blog-id}">&labelInformation;</a>
			<a class="selected" href="{$baseURI}/blogs/edit_blog_members/{@blog-id}">&labelParties;</a>
		</div>
		
		<p>
			<ul id="members_list_control">
				<xsl:apply-templates select="object[@type='blog_member']">
					<xsl:with-param name="blogId" select="@blog-id" />
				</xsl:apply-templates>
			</ul>
		</p>
		<p>
			<img src="{$baseURI}/images/blog-members-manager-admin.png" alt="" /><xsl:text> ― &labelBlogSetAdmin;</xsl:text><br />
			<img src="{$baseURI}/images/blog-members-manager-moderator.png" alt="" /><xsl:text> ― &labelBlogSetModer;</xsl:text><br />
			<img src="{$baseURI}/images/blog-members-manager-member.png" alt="" /><xsl:text> ― &labelBlogSetMember;</xsl:text><br />
		</p>
	</xsl:template>
	
	<xsl:template match="object[@type='blog_member']">
		<xsl:param name="blogId" />
		<xsl:param name="userId" select="property[@name='user_id']/value" />
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		
		<li id="member_{$userId}">
			<xsl:if test="@admin = '1'">
				<xsl:attribute name="class"><xsl:text>admin</xsl:text></xsl:attribute>
			</xsl:if>
			<xsl:if test="@moderator = '1'">
				<xsl:attribute name="class"><xsl:text>moderator</xsl:text></xsl:attribute>
			</xsl:if>
			<div class="inner">
				<div class="name">
					<a href="{$baseURI}/user/{$userLogin}">
						<xsl:value-of select="property[@name='user_name']/value" />
					</a>
				</div>
				<div class="controls" id="user_control_{$userId}">
					<button onclick="manageUser ('admin', {$userId}, {$blogId});">
						<xsl:if test="@admin = '1'">
							<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
							<xsl:attribute name="onclick"><xsl:text></xsl:text></xsl:attribute>
						</xsl:if>
						<img src="{$baseURI}/images/blog-members-manager-admin.png" alt="" />
					</button>
					<button onclick="manageUser ('moderator', {$userId}, {$blogId});">
						<xsl:if test="@moderator = '1'">
							<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
							<xsl:attribute name="onclick"><xsl:text></xsl:text></xsl:attribute>
						</xsl:if>
						<img src="{$baseURI}/images/blog-members-manager-moderator.png" alt="" />
					</button>
					<button onclick="manageUser ('member', {$userId}, {$blogId});">
						<xsl:if test="@admin = '0' and @moderator = '0'">
							<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
							<xsl:attribute name="onclick"><xsl:text></xsl:text></xsl:attribute>
						</xsl:if>
						<img src="{$baseURI}/images/blog-members-manager-member.png" alt="" />
					</button>
				</div>
			</div>
		</li>
	</xsl:template>
	
</xsl:stylesheet>